package com.zipou.framework.persistence;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
 
public class MyInvocationHandler implements InvocationHandler {

	private static final Logger log = Logger.getLogger(MyInvocationHandler.class.getName());
	 
	private Object o;
	
	public MyInvocationHandler(Object o) {
		this.o = o; 
	}	

	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		
////		log.info("Invocation de " + method.getName() + " sur un objet " + proxy.getClass());		
//		if (args != null) {
//			if (args.length != 0) {
//				for (Object o : args) {
////					log.info("Argument: " + o.getClass());
//				}
//			}
//		} else log.info("Arguement Vide pour la methode " + method.getName());
		
		Object obj = null;
		
		try {
			obj  = method.invoke(o, args);
		} catch (InvocationTargetException e){
			throw e.getTargetException();
		}
		
		return obj;
	} 

}
